package com.ecoolex.discount.sales.core.manager;

import com.ecoolex.discount.sales.core.dao.YWCardInfoDAO;
import com.ecoolex.discount.sales.entity.YWBrand;
import com.ecoolex.discount.sales.entity.YWCardInfo;
import com.ecoolex.discount.sales.pojo.YWCardInfoDTO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Date;
import java.time.Instant;

@Service
public class YWCardInfoManager {
    @Autowired
    private YWCardInfoDAO dao;

    public void save(YWCardInfoDTO ywCardInfoDTO){
        YWCardInfo ywCardInfo = new YWCardInfo();
        BeanUtils.copyProperties(ywCardInfoDTO,ywCardInfo);
        ywCardInfo.setStatus(1);
        ywCardInfo.setDeleted(YWCardInfo.NOT_DELETED);
        ywCardInfo.setCreateTime(Date.from(Instant.now()));
        ywCardInfo.setCreateUser("system-admin");
        ywCardInfo.setUpdateUser("system-admin");
        ywCardInfo.setUpdateTime(Date.from(Instant.now()));
        dao.insert(ywCardInfo);
    }
}
